Optimal. Leaf size=93 \[ \frac {a^2 (-d+i c)}{d f (d+i c) (c+d \tan (e+f x))}-\frac {2 i a^2 \log (c \cos (e+f x)+d \sin (e+f x))}{f (c-i d)^2}+\frac {2 a^2 x}{(c-i d)^2} \]
[Out]
________________________________________________________________________________________
Rubi [A] time = 0.19, antiderivative size = 93, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, integrand size = 28, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.107, Rules used = {3542, 3531, 3530} \[ \frac {a^2 (-d+i c)}{d f (d+i c) (c+d \tan (e+f x))}-\frac {2 i a^2 \log (c \cos (e+f x)+d \sin (e+f x))}{f (c-i d)^2}+\frac {2 a^2 x}{(c-i d)^2} \]
Antiderivative was successfully verified.
[In]
[Out]
Rule 3530
Rule 3531
Rule 3542
Rubi steps
\begin {align*} \int \frac {(a+i a \tan (e+f x))^2}{(c+d \tan (e+f x))^2} \, dx &=\frac {a^2 (i c-d)}{d (i c+d) f (c+d \tan (e+f x))}+\frac {\int \frac {2 a^2 (c+i d)+2 a^2 (i c-d) \tan (e+f x)}{c+d \tan (e+f x)} \, dx}{c^2+d^2}\\ &=\frac {2 a^2 x}{(c-i d)^2}+\frac {a^2 (i c-d)}{d (i c+d) f (c+d \tan (e+f x))}-\frac {\left (2 i a^2\right ) \int \frac {d-c \tan (e+f x)}{c+d \tan (e+f x)} \, dx}{(c-i d)^2}\\ &=\frac {2 a^2 x}{(c-i d)^2}-\frac {2 i a^2 \log (c \cos (e+f x)+d \sin (e+f x))}{(c-i d)^2 f}+\frac {a^2 (i c-d)}{d (i c+d) f (c+d \tan (e+f x))}\\ \end {align*}
________________________________________________________________________________________
Mathematica [B] time = 2.95, size = 253, normalized size = 2.72 \[ \frac {a^2 (\cos (e+f x)+i \sin (e+f x))^2 \left (\frac {2 (\cos (2 e)-i \sin (2 e)) \tan ^{-1}\left (\frac {\left (d^2-c^2\right ) \sin (3 e+f x)+2 c d \cos (3 e+f x)}{\left (c^2-d^2\right ) \cos (3 e+f x)+2 c d \sin (3 e+f x)}\right )}{f}-\frac {(c-i d) (c+i d) (\cos (2 e)-i \sin (2 e)) \sin (f x)}{f (c \cos (e)+d \sin (e)) (c \cos (e+f x)+d \sin (e+f x))}+\frac {(-\sin (2 e)-i \cos (2 e)) \log \left ((c \cos (e+f x)+d \sin (e+f x))^2\right )}{f}+4 x (\cos (2 e)-i \sin (2 e))\right )}{(c-i d)^2 (\cos (f x)+i \sin (f x))^2} \]
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
fricas [A] time = 0.49, size = 143, normalized size = 1.54 \[ -\frac {2 \, a^{2} c + 2 i \, a^{2} d + {\left (2 \, a^{2} c + 2 i \, a^{2} d + {\left (2 \, a^{2} c - 2 i \, a^{2} d\right )} e^{\left (2 i \, f x + 2 i \, e\right )}\right )} \log \left (\frac {{\left (i \, c + d\right )} e^{\left (2 i \, f x + 2 i \, e\right )} + i \, c - d}{i \, c + d}\right )}{{\left (-i \, c^{3} - 3 \, c^{2} d + 3 i \, c d^{2} + d^{3}\right )} f e^{\left (2 i \, f x + 2 i \, e\right )} + {\left (-i \, c^{3} - c^{2} d - i \, c d^{2} - d^{3}\right )} f} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
giac [B] time = 0.97, size = 232, normalized size = 2.49 \[ \frac {2 \, {\left (\frac {a^{2} \log \left (c \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - 2 \, d \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - c\right )}{i \, c^{2} + 2 \, c d - i \, d^{2}} + \frac {2 \, a^{2} \log \left (-i \, \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + 1\right )}{-i \, c^{2} - 2 \, c d + i \, d^{2}} - \frac {a^{2} c^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - i \, a^{2} c^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - 2 \, a^{2} c d \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - i \, a^{2} d^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - a^{2} c^{2}}{{\left (i \, c^{3} + 2 \, c^{2} d - i \, c d^{2}\right )} {\left (c \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - 2 \, d \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - c\right )}}\right )}}{f} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
maple [B] time = 0.24, size = 366, normalized size = 3.94 \[ \frac {2 i a^{2} c}{f \left (c^{2}+d^{2}\right ) \left (c +d \tan \left (f x +e \right )\right )}+\frac {a^{2} c^{2}}{f \left (c^{2}+d^{2}\right ) d \left (c +d \tan \left (f x +e \right )\right )}-\frac {a^{2} d}{f \left (c^{2}+d^{2}\right ) \left (c +d \tan \left (f x +e \right )\right )}-\frac {2 i a^{2} \ln \left (c +d \tan \left (f x +e \right )\right ) c^{2}}{f \left (c^{2}+d^{2}\right )^{2}}+\frac {2 i a^{2} \ln \left (c +d \tan \left (f x +e \right )\right ) d^{2}}{f \left (c^{2}+d^{2}\right )^{2}}+\frac {4 a^{2} \ln \left (c +d \tan \left (f x +e \right )\right ) c d}{f \left (c^{2}+d^{2}\right )^{2}}+\frac {4 i a^{2} \arctan \left (\tan \left (f x +e \right )\right ) c d}{f \left (c^{2}+d^{2}\right )^{2}}+\frac {i a^{2} \ln \left (1+\tan ^{2}\left (f x +e \right )\right ) c^{2}}{f \left (c^{2}+d^{2}\right )^{2}}-\frac {i a^{2} \ln \left (1+\tan ^{2}\left (f x +e \right )\right ) d^{2}}{f \left (c^{2}+d^{2}\right )^{2}}+\frac {2 a^{2} \arctan \left (\tan \left (f x +e \right )\right ) c^{2}}{f \left (c^{2}+d^{2}\right )^{2}}-\frac {2 a^{2} \arctan \left (\tan \left (f x +e \right )\right ) d^{2}}{f \left (c^{2}+d^{2}\right )^{2}}-\frac {2 a^{2} \ln \left (1+\tan ^{2}\left (f x +e \right )\right ) c d}{f \left (c^{2}+d^{2}\right )^{2}} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
maxima [B] time = 0.42, size = 213, normalized size = 2.29 \[ \frac {\frac {{\left (2 \, a^{2} c^{2} + 4 i \, a^{2} c d - 2 \, a^{2} d^{2}\right )} {\left (f x + e\right )}}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} + \frac {{\left (-2 i \, a^{2} c^{2} + 4 \, a^{2} c d + 2 i \, a^{2} d^{2}\right )} \log \left (d \tan \left (f x + e\right ) + c\right )}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} + \frac {{\left (i \, a^{2} c^{2} - 2 \, a^{2} c d - i \, a^{2} d^{2}\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} + \frac {a^{2} c^{2} + 2 i \, a^{2} c d - a^{2} d^{2}}{c^{3} d + c d^{3} + {\left (c^{2} d^{2} + d^{4}\right )} \tan \left (f x + e\right )}}{f} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
mupad [B] time = 5.18, size = 139, normalized size = 1.49 \[ -\frac {a^2\,\mathrm {atanh}\left (\frac {c^2+d^2}{{\left (d+c\,1{}\mathrm {i}\right )}^2}+\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (2\,c^4\,d^2+4\,c^2\,d^4+2\,d^6\right )}{{\left (d+c\,1{}\mathrm {i}\right )}^2\,\left (c^3\,d+c^2\,d^2\,1{}\mathrm {i}+c\,d^3+d^4\,1{}\mathrm {i}\right )}\right )\,4{}\mathrm {i}}{f\,{\left (d+c\,1{}\mathrm {i}\right )}^2}+\frac {a^2\,\left (c+d\,1{}\mathrm {i}\right )}{d^2\,f\,\left (\mathrm {tan}\left (e+f\,x\right )+\frac {c}{d}\right )\,\left (c-d\,1{}\mathrm {i}\right )} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
sympy [B] time = 3.53, size = 156, normalized size = 1.68 \[ - \frac {2 i a^{2} \log {\left (\frac {i c - d}{i c e^{2 i e} + d e^{2 i e}} + e^{2 i f x} \right )}}{f \left (c - i d\right )^{2}} + \frac {2 a^{2} c + 2 i a^{2} d}{i c^{3} f + c^{2} d f + i c d^{2} f + d^{3} f + \left (i c^{3} f e^{2 i e} + 3 c^{2} d f e^{2 i e} - 3 i c d^{2} f e^{2 i e} - d^{3} f e^{2 i e}\right ) e^{2 i f x}} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________